#include "ultrasonic.h"

struct Ultrasonic_Information Ult_Info; // ????Ult_Info????

/*
 *????????:Ultrasonic_Mode
 *????????:?????????????
 *????distance:???????????
 *?????:??
 *??  ?:????distance???????2.0 ~ 400.0 cm
 */
void Ultrasonic_Mode(float distance)
{
    Ult_Info.S = HC_SR04_MeasureDistance(); // ????????????

    // printf("????= %d\r\n", (int)Ult_Info.S);

    if (Ult_Info.S <= distance) // ???????50.0cm
    {
        BEEP_ON(); // ??????????0

        sprintf(Ult_Info.VoiceMessage, " %d����\r\n", (int)Ult_Info.S);

        // ?????GBKcoding?????????
        SendVoiceMessages(Ult_Info.VoiceMessage);

        memset(Ult_Info.VoiceMessage, 0, sizeof(Ult_Info.VoiceMessage)); // ??????????????
    }
}
